package com.itheima.design.mode.adapt;

/**
 * 适配器类，实现了 Duck 接口，目的将火鸡转换成鸭子，以假乱真
 */
public class TurkeyAdapter implements Duck{

    Turkey turkey;

    //通过构造方法，获得适配对象实例化的引用
    public TurkeyAdapter(Turkey turkey) {
        this.turkey = turkey;
    }

    @Override
    public void quack() {
        turkey.gobble();
    }

    @Override
    public void fly() {
        for (int i = 0; i < 3; i++) {
            turkey.fly();
        }
    }
}
